<!--河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
-->
<template>
  <div class='app-container'>
    <el-row>
      <el-col :span='22' :xs='24'>
        <el-form ref="form" :model="producecfg" :rules="rules" label-width="100px" id="mvcfm">
          <el-button @click="gotoPage('/psi/product/ProductConfigureAdd?'+vueparams+'')" type='success' size="mini"><i class='fa fa-plus'></i>增加</el-button>
          <div class="form-unit">
            <span class="mvc-title-left"> 构成 </span>
          </div>
          <el-table :data="producecfg">
            <el-table-column label="操作" align="center" width='100' type=''>
              <template slot-scope="scope">
                <el-dropdown trigger="click">
                  <span class="el-dropdown-link">操作<i class="el-icon-arrow-down el-icon--right"></i></span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <el-link @click="gotoPage('/psi/product/ProductConfigureUp?CMID3='+scope.row.product_numid+''+vueparams+'')">修改</el-link>
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <el-link @click="d_num('&CMID3='+scope.row.product_numid+'')">移除</el-link>
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
            <el-table-column label="条形码" prop="product_barcode">
            </el-table-column>
            <el-table-column label="部件名称 " prop="product_name">
            </el-table-column>
            <el-table-column label="部件型号" prop="product_model">
            </el-table-column>
            <el-table-column label="部件规格" prop="product_norm">
            </el-table-column>
            <el-table-column label="部件描述" prop="product_des">
            </el-table-column>
            <el-table-column label="数量" prop="product_numno">
            </el-table-column>
            <el-table-column label="单价" prop="sgproduct_price">
            </el-table-column>
          </el-table>
          <div>
            <el-row>
              <el-col :span="24">
                <el-form-item label="总价" prop="">
                  {{s_total.total_price}}
                </el-form-item>
              </el-col>
            </el-row>
          </div>
        </el-form>
      </el-col>
      <el-col :span='2' :xs='24'>
        <el-menu default-active='active' class='menu-unit'>
          <el-menu-item v-for='item in Container'>
            <el-link @click="gotoMenu(item.url)" :type="'产品配置'===item.name?'primary':'default'">{{item.page_desc||item.name}}</el-link>
          </el-menu-item>
        </el-menu>
      </el-col>
    </el-row>
  </div>
</template>
<script>
  import request from '@/utils/request'
  export default {
    name: 'ProductConfigure',
    components: {},
    props: ['popparams'],
    data() {
      return {
        vueparams: this.getVUEParams(""),
        producecfg: [],
        s_total: {
          total_price: null,
        },
        loading: false,
        Container: null,
        rules: {}
      }
    },
    created() {
      this.getData();
      this.loadContainerMenu({
        pid: "C1BDE411EFF7473EAF5F658AF81F2689",
        name: "产品目录右菜单",
        selected: "产品配置"
      }, 'Container', this.vueparams);
    },
    updated() {},
    mounted() {},
    methods: {
      getData() {
        request({
          method: 'get',
          url: '/xcapi/VUEAction/psi/product/ProductAction/productConfigure?' + this.vueparams,
        }).then(data => {
          for (var k in data) {
            if (Array.isArray(data[k])) {
              this[k] = data[k];
            } else {
              $.extend(this[k], data[k]);
            }
          }
        })
      },
      d_num(_params) {
        request({
          method: 'post',
          url: '/xcapi/VUEAction/psi/product/ProductAction/d_num?' + _params + this.vueparams,
          data: this.postData()
        }).then(data => {
          this.$router.replace("/redirect" + this.$route.fullPath);
          this.msgSuccess(data.msg);
        })
      },
    },
  }
</script>
